﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;
using DataAccessLayer;

namespace ServiceLayer.Entity
{
    [DataContract]
    public class TempPOItemW
    {
        int tempPOID;
        string itemCode;
        int quantity;
        string supplierID;
        int clerkID;
        string date;
        string status;

        [DataMember]
        public int TempPOID
        {
            get { return tempPOID; }
            set { tempPOID = value; }
        }

        [DataMember]
        public string ItemCode
        {
            get { return itemCode; }
            set { itemCode = value; }
        }

        [DataMember]
        public int Quantity
        {
            get { return quantity; }
            set { quantity = value; }
        }

        [DataMember]
        public string SupplierID
        {
            get { return supplierID; }
            set { supplierID = value; }
        }

        [DataMember]
        public int ClerkID
        {
            get { return clerkID; }
            set { clerkID = value; }
        }

        [DataMember]
        public string Date
        {
            get { return date; }
            set { date = value; }
        }

        [DataMember]
        public string Status
        {
            get { return status; }
            set { status = value; }
        }

        public static TempPOItemW convert(TempPOItem tempPOItem)
        {
            TempPOItemW u = new TempPOItemW();

            u.ItemCode = tempPOItem.ItemCode;
            u.Quantity = tempPOItem.Quantity.GetValueOrDefault();
            u.SupplierID = tempPOItem.SupplierID;
            u.ClerkID = tempPOItem.ClerkID.GetValueOrDefault();
            u.Date = tempPOItem.Date.GetValueOrDefault().ToString();
            u.Status = tempPOItem.Status;
            
            return u;
        }

        public static List<TempPOItemW> convertList(List<TempPOItem> list)
        {
            List<TempPOItemW> listW = new List<TempPOItemW>();

            foreach (TempPOItem x in list)
            {
                listW.Add(convert(x));
            }
            return listW;
        }
    }
}